package com.example.testproject.activity

import android.os.Bundle
import android.view.View
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.example.testproject.R
import com.example.testproject.bean.SelectBean
import com.example.testproject.ext.showSelectDialog

/**
 *
 * @ClassName: RvSelectActivity
 * @Author: android 超级兵
 * @CreateDate: 12/20/21$ 6:56 PM$
 * TODO selectRecyclerView
 */
class RvSelectActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_rv_select)
    }

    fun onShowClick(view: View) {
        showSelectDialog(initData()) {
            if (view is Button) {
                view.text = String.format("%s,%s", it.name, it.id)
            }
        }.show(supportFragmentManager, "tag")
    }

    private fun initData() = arrayListOf(
        SelectBean.Data(
            name = "北京", id = "1000", isSelect = true,
            childs = arrayListOf(
                SelectBean.Data(
                    name = "丰台", id = "1001",
                    childs = arrayListOf(
                        SelectBean.Data(
                            name = "右安门街道", id = "1011", childs = arrayListOf(
                                SelectBean.Data(name = "A", id = "1111"),
                                SelectBean.Data(name = "B", id = "1211"),
                                SelectBean.Data(name = "C", id = "1311"),
                                SelectBean.Data(name = "D", id = "1411"),
                                SelectBean.Data(name = "E", id = "1511"),
                                SelectBean.Data(name = "F", id = "1611"),
                                SelectBean.Data(name = "G", id = "1711"),
                                SelectBean.Data(name = "H", id = "1811"),
                                SelectBean.Data(name = "I", id = "1911"),
                                SelectBean.Data(name = "J", id = "1A11"),
                                SelectBean.Data(name = "K", id = "1B11"),
                            )
                        ),
                        SelectBean.Data(
                            name = "太平桥街道", id = "1021",
                            childs = arrayListOf(
                                SelectBean.Data(
                                    name = "右安门街道", id = "1011", childs = arrayListOf(
                                        SelectBean.Data(name = "A1", id = "1111"),
                                        SelectBean.Data(name = "B1", id = "1211"),
                                        SelectBean.Data(name = "C1", id = "1311"),
                                        SelectBean.Data(name = "D1", id = "1411"),
                                        SelectBean.Data(name = "E1", id = "1511"),
                                        SelectBean.Data(name = "F1", id = "1611"),
                                        SelectBean.Data(name = "G1", id = "1711"),
                                        SelectBean.Data(name = "H1", id = "1811"),
                                        SelectBean.Data(name = "I1", id = "1911"),
                                        SelectBean.Data(name = "J1", id = "1A11"),
                                        SelectBean.Data(name = "K1", id = "1B11"),
                                    )
                                ),
                                SelectBean.Data(name = "西罗园街道", id = "1031"),
                                SelectBean.Data(name = "马家堡街道", id = "1041"),
                            ),

                            ),

                        ),
                ),
                SelectBean.Data(name = "昌平", id = "1002"),
                SelectBean.Data(name = "朝阳", id = "1003"),
                SelectBean.Data(name = "顺义", id = "1004"),
                SelectBean.Data(name = "房山", id = "1005"),
            )
        ),
        SelectBean.Data(
            name = "山西", id = "2000",
            childs = arrayListOf(
                SelectBean.Data(
                    name = "小店", id = "2001",
                    childs = arrayListOf(
                        SelectBean.Data(
                            name = "坞城街道", id = "2011", childs = arrayListOf(
                                SelectBean.Data(name = "A", id = "2111"),
                                SelectBean.Data(name = "B", id = "2211"),
                                SelectBean.Data(name = "C", id = "2311"),
                                SelectBean.Data(name = "D", id = "2411"),
                                SelectBean.Data(name = "E", id = "2511"),
                                SelectBean.Data(name = "F", id = "2611"),
                                SelectBean.Data(name = "G", id = "2711"),
                                SelectBean.Data(name = "H", id = "2811"),
                                SelectBean.Data(name = "I", id = "2911"),
                                SelectBean.Data(name = "J", id = "2A11"),
                                SelectBean.Data(name = "K", id = "2B11"),
                            )
                        ),
                        SelectBean.Data(
                            name = "营盘街道", id = "1021",
                            childs = arrayListOf(
                                SelectBean.Data(
                                    name = "东岗路一社区", id = "2011", childs = arrayListOf(
                                        SelectBean.Data(name = "A1", id = "2111"),
                                        SelectBean.Data(name = "B1", id = "2211"),
                                        SelectBean.Data(name = "C1", id = "2311"),
                                        SelectBean.Data(name = "D1", id = "2411"),
                                    )
                                ),
                                SelectBean.Data(name = "北营街道", id = "1031"),
                                SelectBean.Data(name = "平阳路街道", id = "1041"),
                            ),
                        ),
                    ),
                ),
                SelectBean.Data(name = "晋源区", id = "2002"),
                SelectBean.Data(name = "尖草坪区", id = "2003"),
                SelectBean.Data(name = "万柏林区", id = "2004"),
                SelectBean.Data(name = "迎泽区", id = "2005"),
            )
        ),
    )
}


